<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>检测报告-详细报告</title>
    <style type="text/css">
        a.red:link {
            color: #FF0000
        }

        a.red:visited {
            color: #FF0000
        }

        a.red:hover {
            color: #000000
        }

        a.red:active {
            color: #FF5327
        }

        a.orange:link {
            color: orange;
        }

        a.orange:visited {
            color: orange;
        }

        a.orange:hover {
            color: #000000
        }

        a.orange:active {
            color: #FF5327
        }

        body {
            overflow-y: scroll;
            overflow-x: hidden;
        }

        p {
            margin-bottom: 1px;
        }
    </style>
    <link rel="stylesheet" href="css/paper.css">
    <link rel="stylesheet" href="css/word_styles.css">
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body style="OVERFLOW:SCROLL;color: #000000">
<div class="layui-bg-gray" style="padding: 30px;">
    <div class="layui-row layui-col-space16">
        <div class="layui-col-md12">
            <div class="layui-panel">
                <div id="paper-content"
                     style="margin: 30px 50px 50px 50px;height: 100%;min-height:1000px; max-width: 100%">
                </div>
            </div>
        </div>
    </div>
</div>
<div class="zhengwencenter">
    <p>
        检测报告由SameReport文献相似度检测系统生成
    </p>
    <p>
        Copyright © 2007-2024 SameReport
    </p>
</div>
<div style="height:200px;background-color: #FAFAFA;color: #FAFAFA"></div>

<div class="paragraph-edit" id="paragraph-edit-content" style="display: none">
    <div class="paragraph-edit edit-erea">
        <div class="paragraph-edit edit-erea origin-sentence">
            <div class="paragraph-edit edit-erea origin-sentence label">
                原&nbsp;句
            </div>
            <div class="paragraph-edit edit-erea origin-sentence content" id="origin-sentence-content">
            </div>
        </div>
        <div style="float:left;width: 1px;height: 300px; background: #D3D4D3;"></div>
        <div class="paragraph-edit edit-erea edit-form">
            <div class="paragraph-edit edit-erea edit-form label">
                修&nbsp;改
            </div>
            <div class="paragraph-edit edit-erea edit-form content">
                <textarea style="width: 380px;height: 100%;font-size:14px;padding:10px;color: #333333"
                          id="edit-content"></textarea>
            </div>
        </div>
    </div>
    <div class="paragraph-edit tips">
        注：修改完本段落后，点击“临时保存”，修改后的内容可在“修改对照”页面中查看。
        本功能受系统环境影响，无法永久保存修改内容，请尽快将修改后的文章保存到您的论文中。
    </div>
</div>
<script type="application/javascript" src="js/jquery.min.js"></script>
<script type='text/template' id="paragraph-index-template">
    <div class="section_edit ">
        <div class="edit_icon" id="edit_{{path}}" onclick="ParagrphEdit(event)">
            <img style="width: 16px;height: 16px" src="images/bianji.png" alt=""/>
        </div>
    </div>
</script>
<script src="../layui/layui.js"></script>
<script src="js/data.js"></script>
<script type="application/javascript" src="js/mustache.min.js"></script>
<script type="application/javascript">
    layui.use(['dropdown', 'util', 'layer'], function () {
        var element = layui.element;
        var layer = layui.layer;

        //监听折叠
        element.on('collapse(test)', function (data) {
            layer.msg('展开状态：' + data.show);
        });
    });
</script>
<script>
    document_dom.forEach((currentValue, index, arr) => {
        let currentLevelDoms = currentValue;
        currentLevelDoms.forEach((currentValue, index, arr) => {
            let domNode = currentValue;
            let dom = '';
            if (domNode.node === 'body') {
                dom = document.createElement('div');
            } else {
                dom = document.createElement(domNode.node);
            }
            for (let key in domNode.attrs) {
                if (key !== 'id') {
                    dom.setAttribute(key, domNode.attrs[key]);
                }
            }
            dom.setAttribute('id', domNode.path);

            if (domNode.level === 0) {
                document.getElementById('paper-content').appendChild(dom);
            } else {
                let parent_id = domNode.path.split('-' + domNode.node + '_' + domNode.index)[0];
                document.getElementById(parent_id).appendChild(dom);
            }
        })
    });
    sentences.forEach((currentValue, index, arr) => {
        let sentence = currentValue;
        let dom_id = sentence.path;
        let currentNodeName = sentence.path.split('-').pop().split('_')[0];
        if (currentNodeName !== 'tr') {
            if (sentence.is_similar !== 0) {
                let color = 'red';
                if (sentence.is_author === 1) {
                    color = 'orange';
                }
                let sentence_dom = document.createElement('a');
                sentence_dom.setAttribute('target', 'right');
                sentence_dom.setAttribute('href', "SimilarContent.html?index=" + sentence.sentence_id.toString());
                sentence_dom.setAttribute('data-id', sentence.sentence_id.toString());
                sentence_dom.setAttribute('id', 'sentence-'+sentence.sentence_id.toString());
                sentence_dom.setAttribute('class', color);
                sentence_dom.setAttribute('style', 'word-wrap:break-word');
                sentence_dom.innerText = sentence.content;
                document.getElementById(dom_id).appendChild(sentence_dom);
            }
            if (sentence.is_similar === 0) {
                let sentence_dom = document.createElement('span');
                sentence_dom.setAttribute('style', 'word-wrap:break-word');
                sentence_dom.innerText = sentence.content;
                document.getElementById(dom_id).appendChild(sentence_dom);
            }
        } else {
            if (sentence.is_similar !== 0) {
                let spanDoms = document.getElementById(dom_id).getElementsByTagName('span');
                let spanList = Array.from(spanDoms);
                let color = 'red';
                if (sentence.is_author === 1) {
                    color = 'orange';
                }
                spanList.forEach((spanDom, index, arr) => {
                    let spanDomId = spanDom.getAttribute('id');
                    let text = dom_text[spanDomId];
                    let td_text = document.createElement('a');
                    td_text.setAttribute('target', 'right');
                    td_text.setAttribute('href', "SimilarContent.html?index=" + sentence.sentence_id.toString());
                    td_text.setAttribute('data-id', sentence.sentence_id.toString());
                    td_text.setAttribute('id', 'sentence-'+sentence.sentence_id.toString());
                    td_text.setAttribute('class', color);
                    td_text.setAttribute('style', 'word-wrap:break-word');
                    td_text.innerText = text;
                    spanDom.appendChild(td_text)
                })
            } else {
                let spanDoms = document.getElementById(dom_id).getElementsByTagName('span');
                let spanList = Array.from(spanDoms);
                spanList.forEach((spanDom, index, arr) => {
                    let spanDomId = spanDom.getAttribute('id');
                    let text = dom_text[spanDomId];
                    let td_text = document.createElement('span');
                    td_text.setAttribute('style', 'word-wrap:break-word');
                    td_text.innerText = text;
                    spanDom.appendChild(td_text)
                })
            }
        }
    });
    document_dom.forEach((currentValue, index, arr) => {
        let currentLevelDoms = currentValue;
        currentLevelDoms.forEach((currentValue, index, arr) => {
            let domNode = currentValue;
            if (domNode.node === 'p') {
                let need_edit = false;
                let current_node = document.getElementById(domNode.path);
                let current_text = current_node.innerText;
                // current_node.childNodes.some(item=>{
                //     item.childNodes.forEach(item_children=>{
                //         if(item_children.nodeName === 'a'){
                //             need_edit = true;
                //             break f;
                //         }
                //     })
                // })
                f:for (let item of current_node.childNodes) {
                    for (let item_child of item.childNodes) {
                        if (item_child.nodeName === 'A') {
                            need_edit = true
                            break f;
                        }
                    }
                }
                //if (current_text !== "" && need_edit) {
                //    let paragrph_index_dom = document.createElement('div');
                //    let paragrph_index_template = document.getElementById("paragraph-index-template").innerHTML;
                //    view = Mustache.render(paragrph_index_template, {'path': domNode.path});
                //    paragrph_index_dom.innerHTML = view;
                //    document.getElementById(domNode.path).before(paragrph_index_dom)
               // }
            }
        })
    });
</script>
<!--<script>-->
<!--    paper.forEach((currentValue, index, arr) => {-->
<!--        let paragraph = currentValue;-->
<!--        let dom = document.createElement('p');-->
<!--        let sentences = [];-->
<!--        sentences.push('<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>');-->
<!--        paragraph.sentence.forEach(sentence => {-->
<!--            if (sentence.similar === 1) {-->
<!--                let html = "<a href='SimilarContent.html?index=" + sentence.index + "' target='right' class='red' style='word-wrap:break-word' data-id=" + sentence.index + ">" + sentence.context + "</a>";-->
<!--                sentences.push(html)-->
<!--            }-->
<!--            if (sentence.similar === 2) {-->
<!--                let html = "<a href='SimilarContent.html?index=" + sentence.index + "' target='right' class='orange' style='word-wrap:break-word' data-id=" + sentence.index + ">" + sentence.context + "</a>";-->
<!--                sentences.push(html)-->
<!--            }-->
<!--            if (sentence.similar === 0) {-->
<!--                let html = "<span style='word-wrap:break-word'>" + sentence.context + "</span>";-->
<!--                sentences.push(html)-->
<!--            }-->
<!--        });-->
<!--        dom.innerHTML = sentences.join('');-->
<!--        let paragrph_index_dom = document.createElement('div');-->
<!--        let paragrph_index_template = document.getElementById("paragraph-index-template").innerHTML;-->
<!--        view = Mustache.render(paragrph_index_template, {'index': index + 1});-->
<!--        paragrph_index_dom.innerHTML = view;-->
<!--        document.getElementById('document-content').appendChild(paragrph_index_dom);-->
<!--        document.getElementById('document-content').appendChild(dom);-->
<!--    })-->
<!--</script>-->
<script>
    function ParagrphEdit(event) {
        let node_id = event.currentTarget.id.split("edit_")[1];
        let localkey = 'edit_paragraphs_' + order_number;
        if (localStorage.getItem(localkey) === null) {
            localStorage.setItem(localkey, JSON.stringify(document_dom))
        }
        let local_edit_paragraphs = JSON.parse(localStorage.getItem(localkey))
        let paragrph_node = document.getElementById(node_id);
        // document.getElementById('origin-sentence-content').innerHTML = '';
        //
        // let paragraph_index = path[2].innerText - 1;
        // let paragraph_data = paper[paragraph_index].sentence
        // let dom = document.createElement('div')
        // let origin_sentences = ['<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>']
        // let edit_paragraph = local_edit_paragraphs[paragraph_index].content
        // paragraph_data.forEach(item => {
        //     if (item.similar === 1) {
        //         let html = "<a href='SimilarContent.html?index=" + item.index + "' target='right' class='red' style='word-wrap:break-word' data-id=" + item.index + ">" + item.context + "</a>";
        //         origin_sentences.push(html)
        //     }
        //     if (item.similar === 2) {
        //         let html = "<a href='SimilarContent.html?index=" + item.index + "'  target='right' class='orange' style='word-wrap:break-word' data-id=" + item.index + ">" + item.context + "</a>";
        //         origin_sentences.push(html)
        //     }
        //     if (item.similar === 0) {
        //         let html = "<span style='word-wrap:break-word;color: green'>" + item.context + "</span>";
        //         origin_sentences.push(html)
        //     }
        // })
        // dom.innerHTML = origin_sentences.join('')
        // document.getElementById('origin-sentence-content').appendChild(dom);
        // document.getElementById("edit-content").value = edit_paragraph;
        // layer.open({
        //     type: 1,
        //     title: '段落修改',
        //     content: $("#paragraph-edit-content"),
        //     maxmin: true,
        //     offset: '80px'
        //     , area: ['900px', '500px']
        //     , skin: 'layui-layer-molv'
        //     , btn: ['临时保存', '取消保存']
        //     , yes: function (index, layero) {
        //         let edit_content = document.getElementById('edit-content').value;
        //         let origin_paragraph_content = paragraphs[paragraph_index].content;
        //         if (edit_content !== origin_paragraph_content) {
        //             local_edit_paragraphs[paragraph_index].content = edit_content;
        //             local_edit_paragraphs[paragraph_index].edit = 1;
        //             localStorage.setItem(localkey, JSON.stringify(local_edit_paragraphs))
        //         }
        //         layer.close(index)
        //     }
        //     , btn2: function (index, layero) {
        //     }
        //     , cancel: function () {
        //     }
        // });
    }
</script>
</body>
</html>
